﻿Imports System.IO
Public Class Form1

    Dim dossier As String

    Function RecupereIni(ByVal Cle As String) As String

        For Each Ligne As String In File.ReadAllLines("settings.ini")
            'Découpe la ligne au niveau de "=" (s'il existe),
            'compare la premiere partie de la ligne (soit la clé)
            If Ligne.Split("=")(0) = Cle Then
                'Recupère la seconde partie de la ligne (soit la valeur)
                Return Ligne.Split("=")(1)
            End If
        Next
        'Sinon ne retourne rien
        Return ""
    End Function

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If File.Exists("settings.ini") Then
            dossier = RecupereIni("dossier")
            If RecupereIni("auto") = "oui" Then
                If RecupereIni("cache") = "oui" Then
                    If Directory.Exists(dossier & "\Cache") Then
                        Directory.Delete(dossier & "\Cache", True)
                    End If
                End If
                If File.Exists(dossier & "\wow.exe") Then
                    Process.Start(dossier & "\wow.exe")
                Else
                    If File.Exists(dossier & "\game.exe") Then
                        Process.Start(dossier & "\game.exe")
                    Else
                        MsgBox("wow.exe/gameexe introuvable.", MsgBoxStyle.Exclamation, "Smart Launcher WoW")
                    End If
                End If
                If RecupereIni("fermeture") = "oui" Then
                    Me.Close()
                End If
            End If
        Else
            Form3.ShowDialog()
            If Label1.Text = "1" Then
                Me.Close()
            End If
        End If

    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        dossier = RecupereIni("dossier")
        If RecupereIni("cache") = "oui" Then
            Directory.Delete(dossier & "\Cache", True)
        End If
        If File.Exists(dossier & "\wow.exe") Then
            Process.Start(dossier & "\wow.exe")
        Else
            If File.Exists(dossier & "\game.exe") Then
                Process.Start(dossier & "\game.exe")
            Else
                MsgBox("wow.exe/gameexe introuvable.", MsgBoxStyle.Exclamation, "Smart Launcher WoW")
            End If
        End If
        If RecupereIni("fermeture") = "oui" Then
            Me.Close()
        End If
    End Sub

    Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
        PictureBox1.Image = My.Resources.jouer_onclick
    End Sub

    Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
        PictureBox1.Image = My.Resources.jouer_hover
    End Sub

    Private Sub PictureBox1_MouseHover(sender As Object, e As EventArgs) Handles PictureBox1.MouseHover
        PictureBox1.Image = My.Resources.jouer_hover
    End Sub

    Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox1.MouseLeave
        PictureBox1.Image = My.Resources.jouer
    End Sub


    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        Form2.ShowDialog()
    End Sub

    Private Sub PictureBox2_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseDown
        PictureBox2.Image = My.Resources.options_onclick
    End Sub

    Private Sub PictureBox2_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox2.MouseUp
        PictureBox2.Image = My.Resources.options_hover
    End Sub

    Private Sub PictureBox2_MouseHover(sender As Object, e As EventArgs) Handles PictureBox2.MouseHover
        PictureBox2.Image = My.Resources.options_hover
    End Sub

    Private Sub PictureBox2_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox2.MouseLeave
        PictureBox2.Image = My.Resources.options
    End Sub


    Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
        Me.Close()
    End Sub

    Private Sub PictureBox3_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox3.MouseDown
        PictureBox3.Image = My.Resources.quitter_onclick
    End Sub

    Private Sub PictureBox3_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox3.MouseUp
        PictureBox3.Image = My.Resources.quitter_hover
    End Sub

    Private Sub PictureBox3_MouseHover(sender As Object, e As EventArgs) Handles PictureBox3.MouseHover
        PictureBox3.Image = My.Resources.quitter_hover
    End Sub

    Private Sub PictureBox3_MouseLeave(sender As Object, e As EventArgs) Handles PictureBox3.MouseLeave
        PictureBox3.Image = My.Resources.quitter
    End Sub
End Class